package com.example.bob.intent;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {


    private Button btnStartAtry1,btn10086,btnWeb;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnStartAtry1 = (Button) findViewById(R.id.btnStartAty1);
        btnStartAtry1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

//                Intent i = new Intent();
//                i.setComponent(new ComponentName("com.example.bob.intent","com.example.bob.intent.Aty1"));

                Intent i = new Intent("com.example.bob.intent.intent.action.Aty1");
                startActivity(i);
            }
        });
        btn10086 = (Button) findViewById(R.id.btn10086);
        btn10086.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse("tel:10086"));
                startActivity(i);
            }
        });
        btnWeb = (Button) findViewById(R.id.btnWeb);
        btnWeb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse("http://baidu.com"));
                startActivity(i);
            }
        });
    }

}
